package com.yx.fmmall.controller;

import com.yx.fmmall.entity.PersonManager;
import com.yx.fmmall.service.PersonManagerService;
import com.yx.fmmall.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @Classname PersonManagerController
 * @Date 2022/01/04 23:09
 * @Author by yx
 * @Description :
 */
@RestController
@RequestMapping("/personManager")
@Api(value = "登录注册接口", tags = "管理员用户登录")
public class PersonManagerController {

    @Autowired
    private PersonManagerService personManagerService;

    @GetMapping("/login")
    @ApiOperation("用户登录")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String",name = "username",value = "用户账号",required = true),
            @ApiImplicitParam(dataType = "String",name = "password",value = "密码",required = false, defaultValue = "123456")
    })
    public ResultVO login(@RequestParam("username") String name, @RequestParam(value = "password", defaultValue = "123456") String password) {
        // controller只做接收和响应,业务处理交由service进行处理
        return personManagerService.checkLogin(name, password);
    }

    @RequestMapping(value = "/register", method = RequestMethod.POST)
    @ApiOperation("用户注册")
    @ApiImplicitParam(name = "用户信息",required = true)
    public ResultVO register(PersonManager personManager) {
        return new ResultVO(10000, "SUCCESS", null);
    }

    @DeleteMapping("/{userId}")
    public ResultVO testRESTfulOne(@PathVariable("userId") int id){
        return new ResultVO(10000, "delete SUCCESS", null);
    }
    @GetMapping("/{userId}")
    public ResultVO testRESTfulTwo(@PathVariable("userId") int id){
        return new ResultVO(10000, "query SUCCESS", null);
    }
    @PutMapping("/{userId}")
    public ResultVO testRESTfulThere(@PathVariable("userId") int id){
        return new ResultVO(10000, "update SUCCESS", null);
    }
    @PostMapping("/{userId}")
    public ResultVO testRESTfulFour(@PathVariable("userId") int id){
        return new ResultVO(10000, "add SUCCESS", null);
    }
}
